<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    //1 判断类型
    var toString = Object.prototype.toString;
    console.log(toString.call(1));
    console.log(toString.call("1"));
    console.log(toString.call(true));
    console.log(toString.call(undefined));
    console.log(toString.call(NaN));
    console.log(toString.call(new Date()));
    console.log(toString.call(null));
    console.log(toString.call(/^1[356789]\d{9}$/));

    //2 判断类型
    var n = 1;
    console.log(n.constructor);
    n = '1';
    console.log(n.constructor);
    n = true;
    console.log(n.constructor);
    // n = undefined;
    // console.log(n.constructor);
    n = NaN;
    console.log(n.constructor);
    n = new Date();
    console.log(n.constructor);
    // n = null;
    // console.log(n.constructor);
    n = /^1[356789]\d{9}$/;
    console.log(n.constructor);

    // 3 判断类型
    console.log(typeof 1);
    console.log(typeof '1');
    console.log(typeof true);
    console.log(typeof undefined);
    console.log(typeof NaN);
    console.log(typeof new Date());
    console.log(typeof null);
    console.log(typeof /^1[356789]\d{9}$/);
  </script>
</body>

</html>